package com.example.mweather;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.SharedPreferences;
import android.os.Bundle;

import com.example.mweather.adapter.ThemeAdapter;

import java.util.ArrayList;
import java.util.List;

public class ThemeActivity extends AppCompatActivity {
    private RecyclerView rvThemes;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_theme);
        findViewById(R.id.ivBack).setOnClickListener(v -> finish());
        rvThemes = findViewById(R.id.rvThemes);
        rvThemes.setLayoutManager(new GridLayoutManager(this, 3));
        List datas = new ArrayList();
        datas.add(R.mipmap.bg_main_theme1);
        datas.add(R.mipmap.bg_main_theme2);
        datas.add(R.mipmap.bg_main_theme3);
        datas.add(R.mipmap.bg_main_theme4);
        datas.add(R.mipmap.bg_main_theme5);
        datas.add(R.mipmap.bg_main_theme6);
        rvThemes.setAdapter(new ThemeAdapter(this, datas) {
            @Override
            public void selectTheme(Integer theme) {
                SharedPreferences preferences = getSharedPreferences("cities", MODE_PRIVATE);
                preferences.edit().putInt("theme", theme).commit();
                finish();
            }
        });

    }
}